package com.ossean.match.utils;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.LinkedList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

public class Extractor {
	private static Logger logger = LoggerFactory.getLogger(Extractor.class);
	public static  List<String> extractAtoms(String str){
		//System.out.print(name + ">>>");
		str = Normalizer.normalize(str);
		//System.out.print(name + ">>>");
		Reader text = new StringReader(str);
		IKSegmenter iks = new IKSegmenter(text, true);
		Lexeme term = null;
		List<String> items = new LinkedList<String>();
		try {
			while((term = iks.next()) != null){
				if (!Normalizer.isAllNumber(term.getLexemeText().toString())) {
					items.add(term.getLexemeText().toString());		
				}
			}
		} catch (IOException e) {
			logger.error("分词出现错误: " + e);
		}
		return items;
	}
	public static void main(String []args) {
		List<String> atoms = extractAtoms("asddas123 123 asd_132");
		System.out.println(atoms);
	}
}
